//获取消费者行为分析图的数据
import { PieChartList } from '@/services/PieChart';
import { useEffect, useState } from 'react';

type ColumLineChartDataListItem = {
  type: string;
  value: number;
  name: string;
  action: string;
  obj: string;
};
type ColumLineChartDataList = ColumLineChartDataListItem[][];

const usePieChart = (): ColumLineChartDataList => {
  const [pieChart, setpieChart] = useState<ColumLineChartDataList>([]);
  useEffect(() => {
    const fetchData = async () => {
      try {
        const res = await PieChartList();
        if (res.success) {
          console.log('PieChartList:', res.data.PieChart);
          setpieChart(res.data.PieChart);
        }
      } catch (error) {
        console.error('Error fetching PieChartList data:', error);
      }
    };

    fetchData();
  }, []);
  return pieChart;
};

export default usePieChart;
